﻿using System;
using System.ServiceProcess;
using ObjectBuilder;

namespace NServiceBus.Management.ManagementService
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            IBuilder builder = new ObjectBuilder.CastleFramework.Builder();

            builder.ConfigureComponent(typeof (ManagementService), ComponentCallModelEnum.Singleton);


            ManagementService service = builder.Build<ManagementService>();

            if (args.Length > 0 && args[0] == "-d")
            {
                service.Start(args);


                Console.WriteLine("Press 'q' to quit");
                while (Console.ReadLine().ToLower() != "q")
                {
                }
                
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[] 
			{ 
				service
			};
                ServiceBase.Run(ServicesToRun);
            }
        }
    }
}
